// 导入需要的config和request
//import { th } from 'element-plus/es/locale/index.js';
import confing from '../config/config.js';
import request from '../util/request.js';
// 申明请求对象
const processRequest = {
  // process请求的基本url
  BASE_URL: confing.PRO_URL + "/process",
  // 请求的API
  list(page = 1, limit = 10, process, callbcak) {
    // url
    let url = this.BASE_URL + "/list?page=" + page +
      "&limit=" + limit;
    if (process) {
      if (process.processCode) {
        url += "&processCode=" + process.processCode;
      }
      if (process.processName) {
        url += "&processName=" + process.processName;
      }
      if (process.enableFlag) {
        url += "&enableFlag=" + process.enableFlag;
      }
    }
    // 发送请求
    request.get(url, callbcak);
  },
  save(process, callbcak) {
    if (process) {
      request.post(this.BASE_URL + "/save", process, callbcak);
    }
  },
  get(processId, callback) {
    if (processId) {
      let url = this.BASE_URL + "/get?processId=" + processId;
      request.get(url, callback);
    }
  },
  /**
   * 根据ID编辑工序信息
   * @param {*} process 
   * @param {*} callback 
   */
  edit(process, callback) {
    if (process != undefined && process.processId != undefined) {
      request.put(this.BASE_URL + "/update", process, callback);
    }
  },
  /**
   * 根据ID删除工序
   * @param {*} processId 
   * @param {*} callback 
   */
  delete(processId, callback) {
    request.delete(this.BASE_URL + "/delete?processId=" + processId, callback);
  },
}
// 将dictRequest暴漏出去
export default processRequest;